package com.example;

/**
 * 下边提供了三个版本，每个版本都能工作
 */

import android.util.Log;

/**直接访问成员变量*/
public class User {

    private static final String TAG = "DataBinding";
    public final String firstName;
    public final String lastName;
    public String contact;
    private boolean isAdult;

    public User(String firstName, String lastName) {
        this.firstName = firstName;
        this.lastName = lastName;
    }

    public boolean getIsAdult() {
        Log.d(TAG, "calling getIsAdult method");
        return isAdult;
    }

    public void setIsAdult(boolean isAdult) {
        this.isAdult = isAdult;
    }

    public String getContact() {
        Log.d(TAG, "calling getContact method");
        return contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }
}

/**通过getter访问成员变量*/
//public class User {
//
//    private final String firstName;
//    private final String lastName;
//
//    public User(String firstName, String lastName) {
//        this.firstName = firstName;
//        this.lastName = lastName;
//    }
//
//    public String getFirstName() {
//        return firstName;
//    }
//
//    public String getLastName() {
//        return lastName;
//    }
//}
//
//

/**通过firstName()方法访问成员变量*/
//public class User {
//
//    private final String firstName;
//    private final String lastName;
//
//    public User(String firstName, String lastName) {
//        this.firstName = firstName;
//        this.lastName = lastName;
//    }
//
//    public String firstName() {
//        return firstName;
//    }
//
//    public String lastName() {
//        return lastName;
//    }
//}